<#include "../_inc/_layout.html"/> 
<#macro script>


var data={
    url:'',
    alt:''
};

function initTinymce(){
tinymce.init({
        selector: '#textarea',
        height: 500,
        language: 'zh_CN',
        menubar: false,
        automatic_uploads: true,
        paste_data_images: true,
        convert_urls: false,
        imagetools_toolbar: "rotateleft rotateright | flipv fliph | editimage imageoptions",
        imagetools_proxy: '${CPATH}/admin/tinymce/image/proxy',
        images_upload_url: '${CPATH}/admin/tinymce/image/upload',
        wordcount_countregex: /[\u4e00-\u9fa5_a-zA-Z0-9]/g,
		file_picker_callback: function(callback, value, meta) {
		 	layer.open({
			    type: 2,
			    title: '选择图片',
			    shadeClose: true,
			    shade: 0.8,
			    area: ['92%', '90%'],
			    content: '${CPATH}/admin/attachment/choose_layer',
			    end:function(){
			    	callback(data.url, {alt: data.alt});
			    }
			}); 
		 },
        plugins: [
		    "advlist autolink autosave link image imagetools lists charmap print preview hr anchor pagebreak spellchecker",
		    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
		    "table contextmenu directionality emoticons template textcolor paste fullpage textcolor colorpicker textpattern"
		  ],
        toolbar1: '  bold italic underline strikethrough removeformat | blockquote hr table image | link  anchor unlink | alignleft aligncenter alignright alignjustify | bullist numlist  | fullscreen code   ',
        toolbar2: '  formatselect | outdent indent | forecolor backcolor  | undo redo  ',
    });
}


initTinymce();
    
function save(){
	
	$('#comment_slug').attr('value',$("#slug_text").text());
	
	tinymce.activeEditor.uploadImages(function(success) {
			tinymce.triggerSave();
	 		doSubmit();
		});
	return false;
 }
 
 function saveAsDraft(){
 	$("#comment_status").attr("value","draft");
 	save();
 }
 
 function doSubmit(){
 	$("#form").ajaxSubmit({
			type : "post", 
			dataType : "json", 
			success : function(data) { 
				toastr.success(data.message,'操作成功');
				$("#comment_id").attr("value",data.data);
			},
			error : function() {
				alert("信息提交错误");
			}
	});
 }
 
</#macro> 
<#macro script_import>
<script src="${CPATH}/static/tinymce/tinymce.min.js"></script>
</#macro>
<#macro css>
.editable-input {
	width: 100%;
}
.form-inline .form-control {
    display: inline-block;
    width: 100%;
    vertical-align: middle;
}
</#macro>
<@layout active_id=p child_active_id=c>
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>评论编辑</h1>
</section>
<!-- Main content -->
<section class="content" style="z-index: 9999">
	<form action="${CPATH}/admin/comment/save" id="form" method="post">
		<input type="hidden" id="comment_id" name="comment.id" value="${(comment.id)!}"> 
		<input type="hidden" name="comment.status" value="normal" id="comment_status"> 
		<input type="hidden" name="comment.created" value="${(comment.created)!}" > 
		<input type="hidden" name="ucode" value="${ucode}">
		<div class="row">
			<!-- /.col -->
			<div class="col-md-9">
				<div class="form-group">
					<label class="sr-only"></label> 
					评论文章：《<a href="${(contentUrl(comment.content_id))!}" target="_blank">${comment.content_title!}</a>》
				</div>
				<div class="box box-solid">
					<div  class="box-body no-padding">
					<textarea id="textarea"  name="comment.text" >${(comment.text)!}</textarea>
				</div>
				</div>
				
				<div class="box box-solid">
					<div class="box-header with-border">
						<h3 class="box-title">属性设置</h3>
						<div class="box-tools">
							<button type="button" class="btn btn-box-tool" data-widget="collapse">
								<i class="fa fa-minus"></i>
							</button>
						</div>
					</div>
					<!-- /.box-header -->
					<div class="box-body no-padding">
						<!-- Custom Tabs -->
						<div class="nav-tabs-custom">
							<ul class="nav nav-tabs">
								<li class="active">
									<a href="#tab_1" data-toggle="tab">常用</a>
								</li>
								<li>
									<a href="#tab_seo" data-toggle="tab">投票</a>
								</li>
								<li>
									<a href="#tab_position" data-toggle="tab">位置</a>
								</li>
								<li>
									<a href="#tab_metadata" data-toggle="tab">元数据</a>
								</li>
							</ul>
							<div class="tab-content jp-aside-hg ">
								<div class="tab-pane active " id="tab_1">
								<div class="jp-prop-input">
									系统用户: <input type="text" name="username" value="${(comment.username)!}">
								</div>
								<div class="jp-prop-input">
									评论昵称: <input type="text" name="comment.author" value="${(comment.author)!}">
								</div>
								<div class="jp-prop-input">
									邮箱: <input type="text" name="comment.email" value="${(comment.email)!}">
								</div>
								<div class="jp-prop-input">
									IP地址: <input type="text" name="comment.ip" value="${(comment.ip)!}">
								</div>
								<div class="jp-prop-input">
									Flag: <input type="text" name="comment.flag" value="${(comment.flag)!}">
								</div>
								</div>
								<!-- /.tab-pane -->
								<div class="tab-pane jp-prop-box" id="tab_seo">
									<div class="jp-prop-input">
										支持: <input type="text" name="comment.vote_up" value="${(comment.vote_up)!}">
									</div>
									<div class="jp-prop-input">
										反对: <input type="text" name="comment.vote_down" value="${(comment.vote_down)!}">
									</div>
								</div>
								<div class="tab-pane jp-prop-box" id="tab_position">
									<div class="jp-prop-input">
									经度: <input type="text" name="comment.lng" value="${(comment.lng)!}">
									</div>
									<div class="jp-prop-input">
									纬度: <input type="text" name="comment.lat" value="${(comment.lat)!}">
									</div>
								</div>
								<div class="tab-pane" id="tab_metadata">元数据</div>
								<!-- /.tab-pane -->
							</div>
							<!-- /.tab-content -->
						</div>
						<!-- nav-tabs-custom -->
					</div>
				</div>
			</div>
			<!-- /.col -->
			<div class="col-md-3">
			<#include "_action_box.html" /> 
			
			<div class="box box-solid">
				<div class="box-header with-border">
					<h3 class="box-title">昵称</h3>
					<div class="box-tools">
						<button type="button" class="btn btn-box-tool" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<!-- /.box-header -->
				<div class="box-body no-padding ">
					<div class="nav-tabs-custom1">
						<ul class="nav">
							<li>
								<div class="form-group">
									<textarea name="comment.author"  class="form-control "></textarea>
								</div>
								<div class="clr"></div>
							</li>
						</ul>
					</div>
				</div>
				<!-- /.box-body -->
			</div>
			
			
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
	</form>
</section>

</@layout>



